<?php
include_once("district_functions.php");
?>
<html>
	<head>
		<title>District Insert Form </title>
		<link rel = "stylesheet" href = "style.css">
	</head>
	<body>
		<table>
			<tr>
				<td colspan = "2" id = "pageheader">
					health information system
				</td>
			</tr>
			<tr>
				<td id = "mainnav">
					<div class = "menuitem">location</div>
					<div class="menuitem">opd cases</div>
					<div class="menuitem">health promotion</div>
					<div class="menuitem">nutrition</div>
					<div class="menuitem">child welfare</div>
					<div class="menuitem">family planning</div>
				</td>
				<td id="content">
					<div id="divPageMenu">
						<span class="menuitem" >districts</span>
						<span class="menuitem" >sub districts</span>
						<span class="menuitem" >communities</span>
						<span class="menuitem" >view map</span>
						<input type="text" id="txtSearch">
						<span class="menuitem">search</span>		
					</div>
					<div id="divStatus" class="status">
						Status Message:
					</div>
					<div id="divContent">
						<form action="district_insert.php" method="POST">
							<table class="tableForm">
								<tr>
									<td class="label">District ID:</td>
									<td class="field"><input type="text" name="district_id" value=""/></td>
								</tr>
								<tr>
									<td class="label">District Name: </td>
									<td class="field"><input type="text" name="district_name" value=""/></td>
								</tr>
								<tr>
									<td class="label">District Capital: </td>
									<td class="field"><input type="text" name="district_capital" value=""/></td>
								</tr>
								<tr>
									<td class="label">Region ID: </td>
									<td class="field"><input type="text" name="region_id" value=""/></td>
								</tr>
								<tr>
									<td class="label"></td>
									<td class="label"><input type="submit" name="submit" value="add"/></td>
								</tr>
							</table>
						</form>
					</div>
				</td>
			</tr>
		</table>
		
		<?php
			$new_dist = new district();
			
			if(isset($_REQUEST['district_name']) && isset($_REQUEST['district_capital']) && isset($_REQUEST['region_id']) && isset($_REQUEST['district_id'])){
				$districtid = $_REQUEST['district_id'];
				$districtname = $_REQUEST['district_name'];
				$districtcapital = $_REQUEST['district_capital'];
				$regionid = $_REQUEST['region_id'];
				$new_dist -> insert_district($districtid, $districtname, $districtcapital, $regionid);
			}
		?>
	</body>
</html>